// ref https://github.com/WICG/EventListenerOptions/pull/30
function isPassive() {
    var supportsPassiveOption = false;
    try {
        addEventListener("test", null, Object.defineProperty({}, 'passive', {
            get: function () {
                supportsPassiveOption = true;
            }
        }));
    } catch(e) {}
    return supportsPassiveOption;
}

var myScroll,myScroll_2;

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
	capture: false,
	passive: false
} : false);

function scrollTo_test(selectName,degree){
    var _trans = $("#"+selectName)[0].style.transform;
    var _space = _trans.substring(_trans.indexOf('(')+1,_trans.indexOf(','));
    var curspace = _space.substring(0,_space.length-2);
    var _temp = Number(curspace)+Number(degree);
    var max_width =$("#"+selectName).css('width');
    var num_width = max_width.substring(0,max_width.length-2);
    if(_temp>0) return;
    if(Math.abs(_temp)>num_width-50) return;
    console.log(_temp);
    $("#"+selectName).css({
        'webkitTransform':'translate('+_temp+'px, 0px) translateZ(0px)',
        'transform':'translate('+_temp+'px, 0px) translateZ(0px)'
    });
}
function keepCurPosition(selectName){
    var _width =$("#"+selectName).css('width');
    var num_width = _width.substring(0,_width.length-2);
    $("#"+selectName).css({
        'webkitTransform':'translate('+num_width+'px, 0px) translateZ(0px)',
        'transform':'translate('+num_width+'px, 0px) translateZ(0px)'
    });
}

$(function(){
    $(".key_attribute_box .icon_right").on('click',function(){
        scrollTo_test('scroller_1','-90');
    });
    $(".key_attribute_box .icon_left").on('click',function(){
        scrollTo_test('scroller_1','90');
    });

    $("#face_imglist_box .icon_right").on('click',function(){
        scrollTo_test('scroller','-168');
    });
    $("#face_imglist_box .icon_left").on('click',function(){
        scrollTo_test('scroller','168');
    });

    $("#compare_left_left").on('click',function(){
        scrollTo_test('left_scroller','175');
    });
    $("#compare_left_right").on('click',function(){
        scrollTo_test('left_scroller','-175');
    });

    $("#compare_right_left").on('click',function(){
        scrollTo_test('right_scroller','175');
    });
    $("#compare_right_right").on('click',function(){
        scrollTo_test('right_scroller','-175');
    });

});